require(quantmod)
require(PerformanceAnalytics)

getMonth <- function(i)
{
  as.numeric(format(i, format="%m"))
}



getSymbols('^GSPC', from='1900-01-01')
d <- index(GSPC)
m <- lapply(d, getMonth)
t <- monthlyReturn(GSPC)
d <- index(t)
t$month <- lapply(d, getMonth)
boxplot(monthly.returns ~ month, t)
title('Market returns by month')
abline(0,0)
